#include "menu.h"
#include "ui_menu.h"
#include "music.h"

#include <QPainter>
menu::menu(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::menu)
{
    ui->setupUi(this);
//    p1=new music();//不能new第二个muisc
//    p1->clientSocket = this->clientSocket;
}

menu::~menu()
{
    delete ui;

}
void menu::paintEvent(QPaintEvent *event)
{
    QPixmap backgroundPixmap;
    backgroundPixmap.load(":/kg_1725158857974.jpg");
    QPainter painter(this);
    // 根据窗口大小调整图片尺寸，保持图片比例
    QPixmap scaledPixmap = backgroundPixmap.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
    // 将调整后的图片设置为窗口背景
    painter.drawPixmap(this->rect(), scaledPixmap);
}
void menu::clearpmodel()
{
    p1->pModelclear();
}
void menu::on_pushButton_clicked()
{
    this->hide();
    p1 = new music(this->clientSocket);
//    p1->clientSocket = this->clientSocket;
    qDebug()<<"clientSocke22 "<<clientSocket<<endl;
    p1->show();
}
